home *** CD-ROM | disk | FTP | other *** search
/ Micromanía: 150 Juegos 2010 / 150Juegos_16.iso / Shareware / Shape Smash / shape-smash.swf / scripts / mochi / as3 / MochiEventDispatcher.as < prev    next >
Encoding:
Text File  |  2010-05-14  |  1.2 KB  |  51 lines

  1. package mochi.as3
  2. {
  3.    public class MochiEventDispatcher
  4.    {
  5.       private var eventTable:Object;
  6.       
  7.       public function MochiEventDispatcher()
  8.       {
  9.          super();
  10.          eventTable = {};
  11.       }
  12.       
  13.       public function triggerEvent(param1:String, param2:Object) : void
  14.       {
  15.          var _loc3_:Object = null;
  16.          if(eventTable[param1] == undefined)
  17.          {
  18.             return;
  19.          }
  20.          for(_loc3_ in eventTable[param1])
  21.          {
  22.             eventTable[param1][_loc3_](param2);
  23.          }
  24.       }
  25.       
  26.       public function removeEventListener(param1:String, param2:Function) : void
  27.       {
  28.          var _loc3_:Object = null;
  29.          if(eventTable[param1] == undefined)
  30.          {
  31.             eventTable[param1] = [];
  32.             return;
  33.          }
  34.          for(_loc3_ in eventTable[param1])
  35.          {
  36.             if(eventTable[param1][_loc3_] == param2)
  37.             {
  38.                eventTable[param1].splice(Number(_loc3_),1);
  39.             }
  40.          }
  41.       }
  42.       
  43.       public function addEventListener(param1:String, param2:Function) : void
  44.       {
  45.          removeEventListener(param1,param2);
  46.          eventTable[param1].push(param2);
  47.       }
  48.    }
  49. }
  50.  
  51.